masterofmagicfandomcom-20200216-history
User blog:Drake178/Dispel Magic Patch
That was the AI. Dispelling my Possession off its own unit, leaving its enchantments intact. Although, if it did not succeed against the Possession, the dispel would have tried to take the enchantments off instead. Dispel Magic patch, part #1 - Possession and Creature Binding can now be dispelled by the correct player - Confused units under temporary enemy control no longer have the opposite player's spells targeted by dispel-type spells - Uninvolved, recalled, and dead units are no longer valid targets for dispelling - Spell Lock now works when cast in combat - There is now a notification when Spell Lock is dispelled - Spell Lock now correctly protects Haste from being removed - Dispelling Confusion now correctly removes all of its effects Only the first two of these are new, the rest have been fixed in v1.50 too. Unfortunately, I needed the space they occupied to create a comprehensive overall fix. That being said, this will probably not make it into the RC because of its player-friendly, intuitive logic, that doesn't actually match that of the original code, which would remove the player's own enchantments from a unit under a temporary control change Confusion before attempting to remove that Confusion. I won't do that. Neither will I allow a Spell Lock to protect Possession and Creature Binding, or remove enchantments regardless of whether the control change effect is ultimately also removed or not. With that in mind, here's the logic: own unit: no state 2: dispel curses dispel confusion (reset confusion state) state 2: dispel possession/creature binding (swap controller, clear state 2 only), OR dispel enchants/haste - spell lock protects enemy unit: no state 2: dispel possession/creature binding (swap controller), OR dispel enchants/haste - spell lock protects state 2: dispel curses dispel confusion (swap controller, reset confusion state) branch 1: (own not state 2, enemy state 2) dispel curses -> dispel confusion - success: -> clear state (-> swap) -> finished - failed/none: finished branch 2: (own state 2, enemy not state 2) dispel possession/creature binding - success: -> clear state 2 -> swap -> finished - failed/none: dispel spell lock or enchants/haste To install this patch from v1.31, save the text from the link below into a text file, then use the FILESET utility from the Unofficial Patch 1.50 to apply it to wizards.exe (e.g. by typing "FILESET WIZARDS.EXE DISPEL.TXT" at the command prompt of DOSBox). Patch text Installing for the current v1.51 RC (11) is a bit trickier, as it requires the following reversal patch to be applied before the actual dispel patch: Reverse text There is also a modified fix file for v1.51 that, if the dispel patch is applied, will allow modular removal of a previous fix, namely W255FIX.TXT, which corrects Confusion's temporary control change effect becoming permanent at the end of the turn. Finally, for those that want to use this patch with v1.31, here's the second part, which has the fixes to the issues already resolved by Insecticide or v1.50/v1.51. These are outside the areas of the offending function that I needed to resolve the main logic. I did not want to reverse any more that what I felt absolutely necessary, so I separated these out into an individual patch instead. This is for v1.31 only. Do not apply this over v1.40/v1.50/v1.51. Also, this patch, as a whole, is not compatible with CoM. Sorry about that, I'm pretty sure that control change spells there are balanced around not being removable. ; Dispel Magic patch, part #2 ; - Overland-only unit enchantments no longer have 5 times the intended ; resistance against being dispelled in combat ; - Spellcasting units now target the correct effects with dispel-type spells ; - Invulnerability can now be dispelled in combat ; - Possession and Creature Binding can no longer be dispelled by the wrong player ; - Holy Arms no longer prevents the removal of combat-cast Holy Weapon ; enchantments from enemy units (from kyrub's Insecticide) ; - Dispelling unit curses is no longer automatically successful ;---------------------------------------------------------------------------------------- ; use the correct player index for spellcasting units A9911 83 8B A9912 7E 46 A9914 13 83 A9915 7E F8 A9916 08 13 A9917 8B 7E A9918 46 08 A9919 0A 90 ; remove the signed comparisons from the overland enchant check A9B95 C0 C2 A9B96 7D 75 A9B97 03 0C ; remove the x5 multiplier from the overland-only spell costs A9BC4 BA 6B A9BC5 6E C0 A9BC6 00 6E A9BC7 F7 06 A9BC8 EA 53 A9BD0 8A 8B A9BD2 35 30 A9BD3 98 C1 A9BD4 50 E0 A9BD5 8B 05 A9BD6 46 C4 A9BD7 FA 1E A9BD8 D1 C2 A9BD9 E0 9E A9BDA 8B 03 A9BDB 1E D8 A9BDC AA 26 A9BDD C8 8A A9BDE 03 47 A9BDF D8 03 A9BE0 8B 98 A9BE1 07 5B A9BE2 BA 07 A9BE3 24 50 A9BE4 00 26 A9BE5 F7 8B A9BE6 EA 47 A9BE7 C4 1A A9BE8 1E 26 A9BE9 2C 80 A9BEA 91 7F A9BEB 03 18 A9BEC D8 01 A9BED 26 74 A9BEE 8B 07 A9BEF 47 90 A9BF0 1A 90 ; include Invulnerability in the overland enchant loop A9DD6 7D 7F ; check Holy Arms on the right player for Holy Weapon (from Insecticide) A9E46 FE F0 ; remove the signed comparisons from the combat-cast enchant check A9E74 C0 C2 A9E75 7D 75 A9E76 03 0C ; include Invulnerability in the combat-cast enchant loop AA093 7D 7F ; remove the unit curse dispel override AA4A1 81 90 AA4A2 C2 90 AA4A3 F4 90 AA4A4 01 90 Oh, and there's also code for the main patch: $A9A1B: c4 1e 2a 92 les bx, 0x922a //BU_Table@ 8b 46 06 mov ax, bp+6 //XPos 8b 56 08 mov dx, bp+8 //YPos 8b 4e fe mov cx, bp-2 //Player_Index LOOP: 26 3b 47 44 cmp ax, es:bx+0x44 //.XPos 75 0d jnz +13 26 3b 57 46 cmp dx, es:bx+0x46 //.YPos 75 07 jnz +7 26 80 7f 34 00 cmp es:bx+0x34, 0 //.Status = Active 74 0d jz +13 83 c3 6e add bx, 0x6e //sizeof(BU_REC) 47 inc di 3b 3e 88 c5 cmp di, 0xc588 //BU_Count 7c e3 jl -29 e9 .. .. jmp $AA5E3 90 90 90 nop x3 26 8a 47 56 mov al, es:bx+0x56 //.Confusion_State d0 e8 shr al, 1 33 d2 xor dx, dx 26 3a 4f 35 cmp cl, es:bx+0x35 //.Owner 75 01 jz +1 42 inc dx 30 d0 xor al, dl 0f 85 .. .. jnz $AA3D4 BRANCH2: 26 8a 47 23 mov al, es:bx+0x23 //.Combat_Effects high byte a8 60 test al, 0x60 // PossessionF||Cr_BindingF 74 .. jz SPELLOCK ba ac 00 mov dx, 0xac // Possession a8 20 test al, 0x20 // Cr_BindingF 74 02 jz +2 b2 49 mov dl, 0x49 // Creature_Binding 6b d2 24 imul dx, 0x24 //sizeof(SPELL_REC) c4 1e 2c 91 les bx, 0x912c //Spell_Data@ 03 da add bx, dx 06 push es 53 push bx 26 8a 47 17 mov al, es:bx+0x17 //.Realm 98 cbw 50 push ax ff 76 f0 push bp-0x10 //Opponent_Index 26 ff 77 1a push es:bx+0x1a //.Casting_Cost 9a 25 00 38 04 call WIZ_GetSpellStrength() // :09D0 -> :099C 83 c4 06 add sp, 6 8b 4e 0c mov cx, bp+12 //Dispel_Strength 89 cb mov bx, cx 01 c1 add cx, ax b8 fa 00 mov ax, 250 50 push ax 99 cwd f7 eb imul bx f7 f9 idiv cx 89 46 f2 mov bp-14, ax //Dispel_Target 9a d8 00 b0 00 call RNG_Random() // :09F1 -> :09B7 59 pop cx 89 fa mov dx, di 6b d2 6e imul dx, 0x6e //sizeof(BU_REC) c4 1e 2a 92 les bx, 0x922a //BU_Table@ 03 da add bx, dx 3b 46 f2 cmp ax, bp-14 //Dispel_Target 7e 04 jle +4 59 pop cx 59 pop cx eb .. jmp SPELLOCK b0 bf mov al, 0xbf // !(PossessionF) 26 f6 47 23 20 test es:bx+0x23, 0x20 // Cr_BindingF 74 02 jz +2 b0 df mov al, 0xdf // !(Cr_BindingF) 26 20 47 23 and es:bx+0x23, al //.Combat_Effects e9 .. .. jmp STATE2RESETSWAP SPELLOCK: $A9AD0 26 8b 57 3a mov dx, es:bx+0x3a //.Unit_Enchants_LO 26 8b 47 30 mov ax, es:bx+0x30 //.Unit_Index c1 e0 05 shl ax, 5 //sizeof(UNIT_REC) c4 1e c2 9e les bx, 0x9ec2 //Unit_Table@ 03 d8 add bx, ax 26 0b 57 18 or dx, es:bx+0x18 //.Unit_Enchants_LO f6 c6 40 test dh, 0x40 // Spell_LockF 74 .. jz $A9B50 6a 01 push 1 // Sorcery 26 8a 47 03 mov al, es:bx+3 //.Unit_Owner 98 cbw 50 push ax 68 96 00 push 150 9a 25 00 38 04 call WIZ_GetSpellStrength() // :09F8 -> :0A08 83 c4 06 add sp, 6 8b 4e 0c mov cx, bp+12 //Dispel_Strength 89 cb mov bx, cx 01 c1 add cx, ax b8 fa 00 mov ax, 250 50 push ax 99 cwd f7 eb imul bx f7 f9 idiv cx 89 46 f2 mov bp-14, ax //Dispel_Target 9a d8 00 b0 00 call RNG_Random() // :0A04 -> :0A23 59 pop cx 3b 46 f2 cmp ax, bp-14 //Dispel_Target 0f 8f .. .. jg $AA5E3 89 f8 mov ax, di 6b c0 6e imul ax, 0x6e //sizeof(BU_REC) c4 1e 2a 92 les bx, 0x922a //BU_Table@ 03 d8 add bx, ax b8 ff bf mov ax, 0xbfff // !(Spell_Lock) 26 21 47 3a and es:bx+0x3a, ax //.Unit_Enchants_LO 26 8b 57 30 mov dx, es:bx+0x30 //Unit_Index c1 e2 05 shl dx, 5 //sizeof(UNIT_REC) c4 1e c2 9e les bx, 0x9ec2 //Unit_Table@ 03 da add bx, dx 26 21 47 18 and es:bx+0x18, ax //.Unit_Enchants_LO c4 06 2c 91 les ax, 0x912c //Spell_Data@ 05 98 07 add ax, 0x798 //Spell_Lock*sizeof(SPELL_REC) 06 push es 50 push ax e9 .. .. jmp MESSAGE_ENTRY $AA2A2: c4 06 2c 91 les ax, 0x912c //Spell_Data@ 05 78 06 add ax, 0x678 //Confusion*sizeof(SPELL_REC) 06 push es 50 push ax 89 f8 mov ax, di 6b c0 6e imul ax, 0x6e //sizeof(BU_REC) c4 1e 2a 92 les bx, 0x922a //BU_Table@ 03 d8 add bx, ax b0 fd mov al, 0xfd // !(ConfusionF) 26 20 47 22 and es:bx+0x22, al //.Combat_Effects f6 d0 not al 26 20 47 56 and es:bx+0x56, al //.Confusion_State 74 17 jz +23 STATE2RESETSWAP: $AA2C4 b0 fd mov al, 0xfd 26 20 47 56 and es:bx+0x56, al //.Confusion_State 26 8a 4f 35 mov cl, es:bx+0x35 //.Unit_Owner a1 84 c5 mov ax, 0xc584 //GUI_Target_Player 03 06 86 c5 add ax, 0xc586 //GUI_Acting_Player 28 c8 sub al, cl 26 88 47 35 mov es:bx+0x35, al //.Unit_Owner MESSAGE_ENTRY: $AA2E0 a1 8e 99 mov ax, 0x998e //GUI_Sandbox_Segment 50 push ax 50 push ax 9a 22 02 40 00 call LBX_Alloc_Mark() // :11B9 -> :11F8 59 pop cx 6a 33 push 51 68 17 5e push 0x5e17 // "SPECFX" 9a 43 00 50 00 call LBXE_LoadAppend() // :1209 -> :1203 83 c4 06 add sp, 6 89 46 ee mov bp-0x12, ax //Dispel_IMG@ 83 3c 04 cmp si, 4 7c 02 jl +2 59 pop cx 59 pop cx eb .. jmp $AA328 :09D0 -> :099C :09F1 -> :09B7 :09F8 -> :0A08 :0A04 -> :0A23 :11B9 -> :11F8 :1209 -> :1203 Category:Blog posts